// LoopHook： 循环钩子，如果当前未返回undefined则一致执行 
const { SyncLoopHook } = require('tapable')

let num1 = 0
let num2 = 0
let num3 = 0

// 创建实例对象
let hook =  new SyncLoopHook(['name', 'age'])

// 添加事件监听
hook.tap('fn1', function (name, age) {
    console.log('fn1--->', name, age)
    if(++num1 === 1){
        num1 = 0
        return undefined
    }
    return true
})

hook.tap('fn2', function (name, age) {
    console.log('fn2--->', name, age)
    if(++num2 === 2){
        num2 = 0
        return undefined
    }
    return true
})

hook.tap('fn3', function (name, age) {
    console.log('fn3--->', name, age)
})

// 触发事件监听
hook.call('SyncLoopHook', 12)
